<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
        
        <h3>Sửa thông tin người quản trị</h3>
        
        <ul class="content-box-tabs">
       
            <li><a href="index.php?page=user">Table</a></li> <!-- href must be unique and match the id of target div -->
            <li><a href="#tab2" class="default-tab">Forms</a></li>
        </ul>
        
        <div class="clear"></div>
        
    </div> <!-- End .content-box-header -->
    
    <div class="content-box-content">
   		
        

        <div class="content-box-tabs" id="tab2">
    <?php
	$txt_passnew='';$txt_username='';$txt_pass='';$txt_fullname='';$txt_passold='';
	$hide_show=1;$id='';
	if(isset($_GET['id']))
		$id =$_GET['id'];
	
	if(isset($_POST['txt_username']))	{$txt_username=$_POST['txt_username'];$hide_show=0;}
	if(isset($_POST['txt_pass']))	$txt_pass=$_POST['txt_pass'];
	if(isset($_POST['txt_passnew']))	$txt_passnew=$_POST['txt_passnew'];
	if(isset($_POST['txt_fullname']))	$txt_fullname=$_POST['txt_fullname'];
	
	if($hide_show==1)
	{
		$sql3='	SELECT 				*
							FROM 	tbl_nguoidung
							WHERE tbl_nguoidung.id='.$id.'';
		$result3=mysql_query($sql3);
				// Lay du lieu day vao form
		$num=mysql_num_rows($result3);
		if($num==1)
		{
			while($row=mysql_fetch_array($result3))
			{
				$txt_fullname=$row['fullname'];
				$txt_username=$row['username'];
			}
		}
	?>
              
            <form action="index.php?page=user&act=edit&id=<?php echo $id;?>" method="post" enctype="multipart/form-data" name="myForm"  onSubmit="return checkform()" >
                
                <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                    
                  
                    <p>
                        <label>Tên người dùng</label>
                        <input class="text-input small-input" type="text" id="txt_fullname" name="txt_fullname" value="<?php echo $txt_fullname;?>"/> 
                    </p>
                    
                    <p>
                        <label>Tài khoản</label>
                        <input class="text-input small-input" type="text" id="txt_username" name="txt_username" value="<?php echo $txt_username;?>"/> 
                    </p>
                    
                    <p>
                        <label>Mật khẩu mới</label>
                        <input class="text-input small-input" type="password" id="txt_passnew" name="txt_passnew" /> 
                    </p>
                  
                    <p>
                        <input class="button" type="submit" value="Submit" />
                        <input type="reset" value="Nhập lại" name="btn_reset"/>
                        
                    </p>
                    
                </fieldset>
                
                <div class="clear"></div><!-- End .clear -->
                
            </form>
     <?php
	}
	else{
		
		if($row['pass']=(md5.($txt_pass)))
			{	
				$sql='	UPDATE 	tbl_nguoidung
								SET 	
										fullname="'.$txt_fullname.'",
										username="'.$txt_username.'",
										pass="'.(md5($txt_passnew)).'"
										 
								WHERE id='.$id.'';
				$result=mysql_query($sql);
				echo 'Thay đổi thành công!';
				header('refresh:1; index.php?page=user');
			}else{
				echo 'Mật khẩu không đúng';
			}
		}
?>
        </div> <!-- End #tab2 -->
        
              
		
    </div> <!-- End .content-box-content -->
    
</div> <!-- End .content-box -->
<script>
function checkform(){
	var pass = document.myForm.txt_pass.value;
	var passnew = document.myForm.txt_passnew.value;
    if(pass==''|| passnew==''){
		alert('Bạn chưa điền mật khẩu');
		return false;
		}
}
</script>